# @Time : 2021/10/26 10:39
# @Author : Li Kunlun
# @Description : 添加线程


import threading


def show():
    # 获取已激活的线程数，输出结果1
    print(threading.active_count())
    # 查看所有线程信息，输出的结果是一个<_MainThread(...)>带多个<Thread(...)>
    # [<_MainThread(MainThread, started 59304)>]
    # <_MainThread(MainThread, started 59304)>
    print(threading.enumerate())  # see the thread list
    print(threading.current_thread())


def thread_job():
    print('This is a thread of %s' % threading.current_thread())


def main():
    # 添加线程，threading.Thread()接收参数target代表这个线程要完成的任务，需自行定义
    thread = threading.Thread(target=thread_job, )
    thread.start()
    show()


if __name__ == '__main__':
    main()
